import request from '@/utils/request'

export function listCategory(query) {
  return request({
    url: '/manager/category',
    method: 'get',
    params: { 'page': query.page - 1, 'size': query.size, 'sort': query.sort, 'name': query.name }
  })
}

export function listCategoryName() {
  return request({
    url: 'manager/category/list',
    method: 'get'
  })
}

export function listParentCats() {
  return request({
    url: 'manager/category/0',
    method: 'get'
  })
}

export function createCategory(data) {
  return request({
    url: 'manager/category',
    method: 'post',
    data
  })
}

export function readCategory(data) {
  return request({
    url: '/category/read',
    method: 'get',
    data
  })
}

export function updateCategory(data) {
  return request({
    url: '/manager/category',
    method: 'put',
    data
  })
}

export function deleteCategory(data) {
  return request({
    url: '/manager/category/' + data.id,
    method: 'delete'
  })
}
